<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>文档处理工具</title>
    <link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.0.0/css/all.min.css" rel="stylesheet">
    <link href="/static/styles.css" rel="stylesheet">
    <link rel="icon" type="image/x-icon" href="/static/favicon.ico">
</head>
<body class="bg-gray-100 min-h-screen">
    <div class="container mx-auto px-4 py-8">
        <h1 class="text-3xl font-bold text-center mb-8 text-gray-800">文档处理工具</h1>
        
        <!-- 功能选择卡片 -->
        <div class="grid grid-cols-1 md:grid-cols-2 gap-6 mb-8">
            <!-- 图片转PDF卡片 -->
            <div class="bg-white rounded-lg shadow-lg p-6">
                <h2 class="text-xl font-semibold mb-4 text-gray-700">
                    <i class="fas fa-file-pdf text-red-500 mr-2"></i>图片转PDF
                </h2>
                <div class="space-y-4">
                    <div class="border-2 border-dashed border-gray-300 rounded-lg p-6 text-center" id="dropZone">
                        <input type="file" id="imageInput" multiple accept="image/*" class="hidden">
                        <label for="imageInput" class="cursor-pointer">
                            <i class="fas fa-cloud-upload-alt text-4xl text-gray-400 mb-2"></i>
                            <p class="text-gray-600">点击或拖拽图片到此处</p>
                            <p class="text-sm text-gray-500 mt-1">支持多个图片文件</p>
                        </label>
                    </div>
                    <div id="imagePreview" class="grid grid-cols-2 gap-2"></div>
                    <div class="flex items-center space-x-4">
                        <label class="text-gray-600">DPI:</label>
                        <input type="number" id="dpiInput" value="200" min="72" max="600" 
                               class="border rounded px-2 py-1 w-20">
                    </div>
                    <button onclick="convertToPDF()" 
                            class="w-full bg-red-500 text-white py-2 px-4 rounded hover:bg-red-600 transition-colors">
                        转换为PDF
                    </button>
                </div>
            </div>

            <!-- 图片转文字卡片 -->
            <div class="bg-white rounded-lg shadow-lg p-6">
                <h2 class="text-xl font-semibold mb-4 text-gray-700">
                    <i class="fas fa-font text-blue-500 mr-2"></i>图片转文字
                </h2>
                <div class="space-y-4">
                    <div class="border-2 border-dashed border-gray-300 rounded-lg p-6 text-center" id="textDropZone">
                        <input type="file" id="textImageInput" accept="image/*" class="hidden">
                        <label for="textImageInput" class="cursor-pointer">
                            <i class="fas fa-cloud-upload-alt text-4xl text-gray-400 mb-2"></i>
                            <p class="text-gray-600">点击或拖拽图片到此处</p>
                            <p class="text-sm text-gray-500 mt-1">支持单个图片文件</p>
                        </label>
                    </div>
                    <div id="textImagePreview" class="hidden">
                        <img id="previewImage" class="max-w-full h-auto rounded">
                    </div>
                    <div class="flex items-center space-x-4">
                        <label class="text-gray-600">语言:</label>
                        <select id="langSelect" class="border rounded px-2 py-1">
                            <option value="ch">中文</option>
                            <option value="en">英文</option>
                        </select>
                    </div>
                    <button onclick="convertToText()" 
                            class="w-full bg-blue-500 text-white py-2 px-4 rounded hover:bg-blue-600 transition-colors">
                        转换为文字
                    </button>
                </div>
            </div>
        </div>

        <!-- 结果显示区域 -->
        <div id="resultArea" class="bg-white rounded-lg shadow-lg p-6 hidden">
            <h3 class="text-xl font-semibold mb-4 text-gray-700">识别结果</h3>
            <div id="resultContent" class="whitespace-pre-wrap text-gray-600"></div>
            <button onclick="copyResult()" 
                    class="mt-4 bg-gray-500 text-white py-2 px-4 rounded hover:bg-gray-600 transition-colors">
                复制结果
            </button>
        </div>
    </div>

    <!-- 加载动画 -->
    <div id="loadingOverlay" class="fixed inset-0 bg-black bg-opacity-50 hidden flex items-center justify-center">
        <div class="bg-white p-4 rounded-lg shadow-lg">
            <div class="animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500 mx-auto"></div>
            <p class="text-gray-600 mt-2">处理中...</p>
        </div>
    </div>

    <script src="/static/script.js"></script>
</body>
</html> 